package com.twu.user;

/**
 * Created by vishwasdamle on 05/08/14.
 */
public class User {
    private final int uid;
    private static int userCount = 1;
    private final String username;
    private final String name;
    private String password;

    public String getName() {
        return name;
    }

    public enum userType {
        ADMIN,
        CUSTOMER
    };
    userType type;
    public User(String name, String password,userType type) {
        uid = userCount++;
        username = "111-" + (uid + 1000);
        this.name = name;
        this.password = password;
        this.type = type;
    }

    public String getUsername() {
        return username;
    }

    public boolean checkPassword(String password) {
        //System.out.println("pass " + password + " user " + username);
        return this.password.equalsIgnoreCase(password);
    }

    public int getUid() {
        return uid;
    }

    public String getDetails() {
        return "User ID : \t\t" + uid + "\nUsername : \t\t" + username + "\nUser Name : \t" + name ;
    }

    public userType getType() {
        return type;
    }

    @Override
    public boolean equals(Object obj) {
        if(obj.getClass() != this.getClass())
        {
            return false;
        };
        return (this.uid == ((User) obj).uid);
    }
}
